# -*- coding=utf-8
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client

# SecretId:AKIDa2GYfaHk392hBUdfYTNQGxRiokU0JOGu
# SecretKey:T1OXqEHAsQGwRkrmU0KRL1udBWfkeQ5Z
secret_id = 'AKIDa2GYfaHk392hBUdfYTNQGxRiokU0JOGu'      # 替换为用户的 secretId
secret_key = 'T1OXqEHAsQGwRkrmU0KRL1udBWfkeQ5Z'      # 替换为用户的 secretKey
region = 'ap-shanghai'     # 替换为用户的 Region

config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)
# 2. 获取客户端对象
client = CosS3Client(config)

# 上传文件
response = client.upload_file(
    Bucket='test01-1349679275',
    LocalFilePath='code.png',  # 本地文件的路径
    Key='p1.png', #  上传到桶之后的文件名
)
print(response['ETag'])